//
//  OAInputRootView.m
//  OASystem
//
//  Created by zhoupengfei on 15/11/22.
//  Copyright © 2015年 zpf. All rights reserved.
//

#import "OAInputRootView.h"
#import "OAInputOpinionView.h"
#import "HttpTools.h"
@implementation OAInputRootView

-(void)awakeFromNib{
    OAInputOpinionView * inputOpinionView = [OAInputOpinionView inputOpinionView];
    inputOpinionView.frame = CGRectMake(0, 0,[UIScreen mainScreen].bounds.size.width, 44);
    [self addSubview:inputOpinionView];
    
}
-(void)updata:(NSArray*)array{
//    NSMutableArray * dataArray = [NSMutableArray array];
    for (NSInteger index = 0 ; index < array.count; index++) {
        NSDictionary * dict = array[index];

        OAInputOpinionView * inputOpinionView = self.subviews[index];
    inputOpinionView.nameTextField.text  = dict[@"name"];
        inputOpinionView.jobTitleTextField.text  = dict[@"work_phone"];
        inputOpinionView.connectMethodTextField.text  = dict[@"tel"];

               //[dataArray addObject:dict];
    }
    
}


-(void)addInputOpinionView{
    OAInputOpinionView * inputOpinionView = [OAInputOpinionView inputOpinionView];
    [self addSubview:inputOpinionView];
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    CGFloat y = 0;
    for (NSInteger index = 0 ; index < self.subviews.count; index++) {
        OAInputOpinionView * inputOpinionView = self.subviews[index];
        inputOpinionView.frame = CGRectMake(0, y,[UIScreen mainScreen].bounds.size.width, 44);
        y += 44;
        inputOpinionView.tag = index;
    }
}

-(CGFloat)inputRootViewHeight{
    CGFloat height = 0;
    for (NSInteger index = 0 ; index < self.subviews.count; index++){
        height += 44;
    }
    return height;
}

-(NSMutableArray*)getInfo{
    NSMutableArray * dataArray = [NSMutableArray array];
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    for (NSInteger index = 0 ; index < self.subviews.count; index++) {
        OAInputOpinionView * inputOpinionView = self.subviews[index];
        if ([inputOpinionView.nameTextField.text length] !=0) {
             [dict setObject:inputOpinionView.nameTextField.text forKey:@"name"];
        }
        
        if ([inputOpinionView.jobTitleTextField.text length]) {
             [dict setObject:inputOpinionView.jobTitleTextField.text forKey:@"jobTitle"];
        }
       
        if ([inputOpinionView.connectMethodTextField.text length]) {
              [dict setObject:inputOpinionView.connectMethodTextField.text forKey:@"connectMetod"];
        }

        [dataArray addObject:dict];
    }
    
    return dataArray;
}

@end
